package com.heima.kafka.listener;

import com.alibaba.fastjson.JSON;
import com.heima.kafka.pojos.User;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;

/**
 * @author 黄晏凯
 */
@Component
public class HelloListener {

    @KafkaListener(topics = "itcast-topic")
    public void onMessage(String msg) {
        System.out.println(msg);
    }

    @KafkaListener(topics = "user-topic")
    public void onMessageObj(String msg) {
        System.out.println(msg);

        User user = JSON.parseObject(msg, User.class);
        System.out.println(user);
    }


}